// then-fs 模块是第三方模块，需要 npm install then-fs  下载安装的
const fs = require('then-fs');

// then-fs 对内置的fs模块进行了重写的封装。调用方法后，返回Promise对象

let p1 = fs.readFile('./files/a.txt', 'utf-8');  // 
let p2 = fs.readFile('./files/b.txt', 'utf-8');
let p3 = fs.readFile('./files/c.txt', 'utf-8');

// 通过then获取结果
p1.then(res => {
  console.log(res.length);
  return p2;
}).then(res => {
  console.log(res.length);
  return p3;
}).then(res => {
  console.log(res.length);
})

setTimeout(() => {
  console.log(999)
}, 1000)